package model
{
	//服务器列表
	
	import flash3.framework.ListManager;
	import flash3.framework.Singleton;
	
	import vo.GameServer;
	
	public class GameServerModel extends ListManager
	{
		public function GameServerModel()
		{
			super();
		}
		
		static public function get i():GameServerModel
		{
			return Singleton.getInstanceOrCreate(GameServerModel) as GameServerModel;
		}
		
		public function getServer(kindid:uint, serverid:uint):GameServer
		{
			var gameServer:GameServer = null;
			for(var i:uint=0;i<list.length;i++)
			{
				gameServer = list[i] as GameServer;
				if(gameServer.wKindID == kindid && gameServer.wServerID == serverid)
				{
					return gameServer;
				}
			}
			return null;
		}
		public function parseJson(data:Object):void
		{
			var servers:Array = data as Array;
			for(var i:uint = 0; i < servers.length; i++)
			{
				var server:Object = servers[i];
				var gameServer:GameServer = new GameServer();
				gameServer.wKindID = server.kindid;
				gameServer.wServerID = server.serverid;
				gameServer.wServerPort = server.serverport;
				gameServer.dwServerAddr = server.serveraddr;
				gameServer.dwOnLineCount = server.onlnecount;
				gameServer.dwCellMoney = server.cellscore;
				gameServer.dwServerType = server.servertype;
				gameServer.dwEnterFee = server.enterfee;
				gameServer.szServerName = server.gameroomname;
				gameServer.szMoneyName = server.moneyname;
				GameServerModel.i.add(gameServer);
			}
		}
	}
}